/*
 * @Author: LVGRAPE
 * @LastEditors: LVGRAPE
 */
#ifndef __RGB_H_
#define __RGB_H_

#include "usr_def.h"

typedef enum rgb_state
{
    RGB_STATE_RF_ERROR,
    RGB_STATE_RF_TEST_ERROR,
    RGB_STATE_OP_TEST_ERROR,
    RGB_STATE_RC_CALI,
    RGB_STATE_LOW_BATTERY,
    RGB_STATE_PAIRING,
    RGB_STATE_ARMING,
    RGB_STATE_ARMED,
    RGB_STATE_CALIBRATING,
    RGB_STATE_PROGRAMING,
    RGB_STATE_RC_LOST,
    RGB_STATE_STANDBY,
    RGB_STATE_COUNT,
};
#define LED_P1 P20
#define LED_P2 P34
#define LED_P3 P00
#define LED_P4 P01
#define LED_P5 P02
#define LED_P6 P03
#define RGB_STATE_SET(X) (rgb_state |= (0X0001<<(X)))
#define RGB_STATE_CLR(X) (rgb_state &= ~(0X0001<<(X)))
#define RGB_STATE_GET(X) (rgb_state & (0X0001<<(X)))
void led_init();
void rgb_pwm_init(void);
void rgb_task_init(void);
void rgb_set(uint8_t r, uint8_t g, uint8_t b);
void rgb(int argc, char **argv);
void rgb_state_handle();//10ms
void led_loop(void);//1mm
void led_state_handle(void);//1ms
extern uint16_t rgb_state;
extern uint8_t led_bits;
extern uint8_t led_dins[6];
extern int8_t speed_fix;
#define LED_SET(X) (led_bits |= (0X01<<(X)))
#define LED_CLR(X) (led_bits &= ~(0X01<<(X)))

#endif // !__RGB_H_
